package com.yx.modules.api.controller;

import java.util.List;
import java.util.Map;

import com.yx.common.utils.PageUtils;
import com.yx.common.utils.Query;
import com.yx.common.utils.R;
import com.yx.modules.api.entity.TbGradeRecord;
import com.yx.modules.api.service.TbGradeRecordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 评分记录
 * 
 * @author luo
 * @email www.baidu.com
 * @date 2018-06-20 10:06:11
 */
@RestController
@RequestMapping("/api/graderecord")
public class TbGradeRecordController {
	@Autowired
	private TbGradeRecordService gradeRecordService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<TbGradeRecord> gradeRecordList = gradeRecordService.queryList(query);
		int total = gradeRecordService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(gradeRecordList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	public R info(@PathVariable("id") Integer id){
		TbGradeRecord gradeRecord = gradeRecordService.queryObject(id);
		
		return R.ok().put("gradeRecord", gradeRecord);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	public R save(@RequestBody TbGradeRecord gradeRecord){
		gradeRecordService.save(gradeRecord);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	public R update(@RequestBody TbGradeRecord gradeRecord){
		gradeRecordService.update(gradeRecord);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	public R delete(@RequestBody Integer[] ids){
		gradeRecordService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
